/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationLimiterDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.CommunicationLimiterDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationLimiterDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_communication_limiter.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisCommunicationLimiterDAO extends SqlMapClientDaoSupport implements
                                                                         CommunicationLimiterDAO {

    /**
     *  Query DB table <tt>sgw_communication_limiter</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select communication_id, max_counter, gmt_create, gmt_modified from sgw_communication_limiter</tt>
     *
     *	@return List<CommunicationLimiterDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<CommunicationLimiterDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-COMMUNICATION-LIMITER-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>CommunicationLimiterDO</tt> object to DB table <tt>sgw_communication_limiter</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_communication_limiter(communication_id,max_counter,gmt_create,gmt_modified) values (?, ?, sysdate, sysdate)</tt>
     *
     *	@param communicationLimiter
     *	@return int
     *	@throws DataAccessException
     */
    public String insert(CommunicationLimiterDO communicationLimiter) throws DataAccessException {
        if (communicationLimiter == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-COMMUNICATION-LIMITER-INSERT", communicationLimiter);

        return communicationLimiter.getCommunicationId();
    }

    /**
     *  Query DB table <tt>sgw_communication_limiter</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select communication_id, max_counter, gmt_create, gmt_modified from sgw_communication_limiter where (communication_id = ?)</tt>
     *
     *	@param communicationId
     *	@return CommunicationLimiterDO
     *	@throws DataAccessException
     */
    public CommunicationLimiterDO selectById(String communicationId) throws DataAccessException {

        return (CommunicationLimiterDO) getSqlMapClientTemplate().queryForObject(
            "MS-COMMUNICATION-LIMITER-SELECT-BY-ID", communicationId);

    }

    /**
     *  Update DB table <tt>sgw_communication_limiter</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_communication_limiter set max_counter=?, gmt_modified=sysdate where (communication_id = ?)</tt>
     *
     *	@param maxCounter
     *	@param communicationId
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(int maxCounter, String communicationId) throws DataAccessException {
        Map param = new HashMap();

        param.put("maxCounter", new Integer(maxCounter));
        param.put("communicationId", communicationId);

        return getSqlMapClientTemplate().update("MS-COMMUNICATION-LIMITER-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_communication_limiter</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_communication_limiter where (communication_id = ?)</tt>
     *
     *	@param communicationId
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(String communicationId) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-COMMUNICATION-LIMITER-DELETE", communicationId);
    }

}